﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net;
using System.Xml;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        //this._fileCodeType = Encoding.Default.HeaderName;
        //this._sendAdress = "http://122.200.77.96/sendMMS";


        ////Textbox1.Text = EncodeBase64("GBK", "彩信内容");

        byte[] data = File.ReadAllBytes(Server.MapPath("~/css/1.mid"));
        string url = Convert.ToBase64String(data);
        ////data:image/png;base64,
        //string img = string.Format("<img src='data:image/jpg;base64,{0}'/>", url);
        //string str16 = zhuan16jinzhi(Server.MapPath("~/css/3.jpg"));
        ////z16toimg(str16);
        //string teststr2 = string.Empty;
        //for (int i = 0; i < str16.Length; i++)
        //{
        //    teststr2 += Convert.ToString((int)str16[i], 2);
        //}
        //UnicodeEncoding ue = new UnicodeEncoding();
        //byte[] b1 = ue.GetBytes(str16);
        ////Response.w
        //string str64 = Convert.ToBase64String(b1);
        //System.Drawing.Image bmp1 = GetImageFromBase64String(str64);
        //bmp1.Save(Server.MapPath("~/imgfile/31.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
        //byte str2 = Convert.ToByte(str16,16);
        //Textbox1.Text = img;
        //4D546864000000060001001101E04D54726B0000001900FF51030B71B000FF58040402180800FF5902000000FF2F004D54726B000000A000C000009048648E7F90480001904A648E7F904A0001904C648E7F904C0001904D648E7F904D0001904F648E7F904F0001904D648E7F904D0001904C648E7F904C0001904A648E7F904A00019048648E7F90480001904A648E7F904A0001904C648E7F904C0001904D648E7F904D0001904F648E7F904F0001904D648E7F904D0001904C648E7F904C0001904A648E7F904A00019048648E7F90480000FF2F004D54726B000000A000C10000913C648E7F913C0001913E648E7F913E00019140648E7F914000019141648E7F914100019143648E7F914300019141648E7F914100019140648E7F91400001913E648E7F913E0001913C648E7F913C0001913E648E7F913E00019140648E7F914000019141648E7F914100019143648E7F914300019141648E7F914100019140648E7F91400001913E648E7F913E0001913C648E7F913C0000FF2F004D54726B0000000700C24F00FF2F004D54726B0000000700C37000FF2F004D54726B0000000700C43800FF2F004D54726B0000000700C54500FF2F004D54726B0000000700C64900FF2F004D54726B0000000700C70000FF2F004D54726B0000000700C80000FF2F004D54726B0000000700C90000FF2F004D54726B0000000700CA0000FF2F004D54726B0000000700CB0000FF2F004D54726B0000000700CC0000FF2F004D54726B0000000700CD0000FF2F004D54726B0000000700CE0000FF2F004D54726B0000000700CF0000FF2F00
        //this.Image1.im
        //System.Drawing.Image bmp = GetImageFromBase64String("/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCACKAO4DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmq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DCopgZiqegJbOc806P4SxSLEjardlYjuTy4VBH5jmvU7dVyPlH5Veg+4KXs49h+2n3OJ0zwHJawxRQ6zfwohYkqiKW3dc4FdXZ6JDblTJNLcOvRpece9aA6L9BUx/1JPt/Ss/ZQvsDqSluxBEqqP9mjCYGa4OTUr/AO3bfttzt3dPNbH866SV35+dvzrRRRk2ap8sZzx9TTDPbKeXT865+Z3wfmb86ozu+fvN19a0UEyT/9k=");
        //bmp.Save(Server.MapPath("~/imgfile/2.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //string xmlFileName = Server.MapPath("XMLFile2.xml");
        ////string url = "http://122.200.77.96/sendMMS";
        ////PostHelp ph = new PostHelp();
        ////读取XML
        //System.IO.StreamReader sr = new System.IO.StreamReader(xmlFileName, Encoding.GetEncoding(this._fileCodeType));
        //string stra = sr.ReadToEnd();
        ////转换成UTF8格式/////////////////////////////////////////////////////////////////////////////////////////
        //byte[] convertbyte = Encoding.GetEncoding(this._fileCodeType).GetBytes(stra);
        //byte[] tempbyte = Encoding.Convert(Encoding.GetEncoding(this._fileCodeType), Encoding.UTF8, convertbyte);
        //string convertstring = Encoding.UTF8.GetString(tempbyte);
        ////string b64Stra = EncodeBase64("UTF-8", convertstring);
        //string back = ph.PostXml(url, convertstring);


    }


    
    
   
    private string _fileCodeType;
    private string _sendAdress;
  
    #region 属性
    /// <summary>
    /// 待发送文件的编码
    /// </summary>
    public string FileCodeType
    {
     get
     {
      return _fileCodeType;
     }
     set
     {
      _fileCodeType = value;
     }
    }
    /// <summary>
    /// 发送地址的URI
    /// </summary>
    public string SendAdress
    {
     get
     {
      return _sendAdress;
     }
     set
     {
      _sendAdress = value;
     }
    }
    #endregion

    #region Base64编码与解码
    /// <summary>
    /// Base64编码
    /// </summary>
    /// <param name="code_type">字符串编码类型</param>
    /// <param name="code">需要Base64编码的字符串</param>
    /// <returns>经过Base64编码的字符串</returns>
    private string EncodeBase64(string code_type, string code)
    {
     string encode = "";
     byte[] bytes = System.Text.Encoding.GetEncoding(code_type).GetBytes(code);
     try
     {
      encode = Convert.ToBase64String(bytes);
     }
     catch
     {
      encode = code;
     }
     return encode;
    }

    /// <summary>
    /// Base64解码
    /// </summary>
    /// <param name="code_type">字符串解码类型</param>
    /// <param name="code">需要Base64解码的字符串</param>
    /// <returns>经过Base64解码的字符串</returns>
    private string DecodeBase64(string code_type, string code)
    {
     string decode = "";
     byte[] bytes = Convert.FromBase64String(code);
     try
     {
      decode = Encoding.GetEncoding(code_type).GetString(bytes);
     }
     catch
     {
      decode = code;
     }
     return decode;
    }
    #endregion
    
    #region 发送xml文件数据并接受返回信息
    /// <summary>
    /// 发送xml文件数据并接受返回信息
    /// </summary>
    /// <param name="path">文件路径</param>
    /// <returns>返回信息的原始编码字符串</returns>
    public string OperationXML(string path)
    {
        //读取XML
        System.IO.StreamReader sr = new System.IO.StreamReader(@path, Encoding.GetEncoding(this._fileCodeType));
        string stra = sr.ReadToEnd();
        //转换成UTF8格式/////////////////////////////////////////////////////////////////////////////////////////
        byte[] convertbyte = Encoding.GetEncoding(this._fileCodeType).GetBytes(stra);
        byte[] tempbyte = Encoding.Convert(Encoding.GetEncoding(this._fileCodeType), Encoding.UTF8, convertbyte);
        string convertstring = Encoding.UTF8.GetString(tempbyte);
        /////////////////////////////////////////////////////////////////////////////////////////////////////////
        string b64Stra = EncodeBase64("UTF-8", convertstring);
        byte[] send = System.Text.Encoding.UTF8.GetBytes(b64Stra);
        //发出对统一资源标识符 (URI) 的请求。
        System.Net.HttpWebResponse MyWebResponse;
        System.Net.HttpWebRequest MyWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(this._sendAdress);
        //MyWebRequest.Headers.Add("ContentType", "text/xml; charset=utf-8"); //指定字符集  
        //MyRequest.Headers.Add("ContentLength",data.Length.ToString());
        MyWebRequest.ContentType = "application/x-www-form-urlencoded";
        MyWebRequest.ContentLength = send.Length;
        MyWebRequest.AllowAutoRedirect = true;
        MyWebRequest.Method = "POST";
        System.IO.Stream newStream = MyWebRequest.GetRequestStream();
        newStream.Write(send, 0, send.Length);
        newStream.Flush();
        newStream.Close();
        sr.Close();
        //上面这一段程序就是把post里面的xml消息包送到指定的RUI去了   
        //下面是接收返回的消息的代码   
        MyWebResponse = (System.Net.HttpWebResponse)MyWebRequest.GetResponse();
        System.IO.Stream ReceiveStream = MyWebResponse.GetResponseStream();
        System.IO.StreamReader readStream = new System.IO.StreamReader(ReceiveStream, System.Text.Encoding.UTF8);
        Char[] read = new Char[256];
        System.Text.StringBuilder str = new System.Text.StringBuilder();
        int count;
        do
        {
            count = readStream.Read(read, 0, 256);
            str.Append(read, 0, count);
        } while (count > 0);
        readStream.Close();
        MyWebResponse.Close();
        string receive = DecodeBase64("UTF-8", str.ToString());
        return receive;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        OperationXML(Server.MapPath("XMLFile2.xml"));
    }


  #endregion



private string GetBase64String(System.Drawing.Image image)
    {
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
 
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        byte[] buffer = ms.ToArray();
 
        return Convert.ToBase64String(buffer);
    }
    private string FixBase64ForImage(string ImageText)
    {
        System.Text.StringBuilder sbText = new System.Text.StringBuilder(ImageText, ImageText.Length);
        sbText.Replace("/r/n", String.Empty);
        sbText.Replace(" ", String.Empty);
        return sbText.ToString();
    }
 
    private System.Drawing.Image GetImageFromBase64String(string ImageText)
    {
        if (ImageText.Length > 0)
        {
            Byte[] bitmapData = new Byte[ImageText.Length];
 
            //bitmapData = Convert.FromBase64String(FixBase64ForImage(ImageText));
            bitmapData = Convert.FromBase64String(ImageText);
            System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);
            //    Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap));
            return System.Drawing.Image.FromStream(streamBitmap);
        }
        else
        {
            return null;
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {

        //FileStream fs = new FileStream("d:\\cc.png", FileMode.Open, FileAccess.Read);
        //BinaryReader br = new BinaryReader(fs);
        //StreamWriter sw = new StreamWriter("d:\\bb.txt");
        //int length = (int)fs.Length;
        //while (length > 0)
        //{
        //    byte tempByte = br.ReadByte();
        //    string tempStr = Convert.ToString(tempByte, 16);
        //    sw.WriteLine(tempStr);
        //    length--;
        //}
        //fs.Close();
        //br.Close();
        //sw.Close();



        FileStream fs = null;
        BinaryWriter bw = null;
        StreamReader sr = null;
        try
        {
            fs = new FileStream("D://cc.jpg", FileMode.Create, FileAccess.Write);
            bw = new BinaryWriter(fs);
            sr = new StreamReader("D://bb.txt");
            while (sr.Peek() != -1)
            {
                string tempStr = sr.ReadLine();
                int tempInt = Convert.ToInt16(tempStr, 16);
                byte tempByte = Convert.ToByte(tempInt);
                bw.Write(tempByte);
            }

        }
        catch (Exception exce)
        {

            //MessageBox.Show(exce.Message);
        }
        finally
        {
            sr.Close();
            bw.Close();
            fs.Close();
        }  
    }



    protected string zhuan16jinzhi(string imgpath)
    {

        FileStream fs = null;
        BinaryReader br = null;
        StringBuilder sb= new StringBuilder();

        try
        {

            fs = new FileStream(imgpath, FileMode.Open, FileAccess.Read);
            br = new BinaryReader(fs);
            //sw = new StreamWriter("bb.txt");
            int length = (int)fs.Length;
            while (length > 0)
            {
                byte tempByte = br.ReadByte();
                int tempInt = Convert.ToInt32(tempByte);
                string tempStr = Convert.ToString(tempInt, 16); //Convert.ToBase64String("",);
                sb.Append(tempStr+";");
                length--;
            }
        }
        catch (Exception exce)
        {
            //MessageBox.Show(exce.Message);
        }
        finally
        {
            br.Close();
            fs.Close();
        }

        return sb.ToString();
    }

    protected void z16toimg(string str16)
    {
        FileStream fs = new FileStream("D:\\cc.jpg", FileMode.Create, FileAccess.Write);
        
    
    }
}